﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Register.IDAL;
using Register.Model;
using Register.DALFactory;
using Register.Command;

namespace Register.BLL
{
    /// <summary>
    /// FileName: AdminInfoBLL.cs
    /// CLRVersion: 4.0.30319.269
    /// Author: WangYan
    /// Corporation: 
    /// Description: 
    /// DateTime: 2012/6/26 10:13:34
    /// </summary>
   public class AdminInfoBLL
    {
       private static String typeNameKey = "IAdminInfoDALKey";

       public static bool AddAdminInfo(Model.AdminInfo model)
       {
           IAdminInfoDAL iAdminInfo = DALFactory<IAdminInfoDAL>.Create(typeNameKey);
           try
           {
               if (iAdminInfo.AddAdminInfo(model) > 0)
                   return true;
               else
                   return false;
           }
           catch (Exception e)
           {
               LogRecordHelper.LogNote("ERROR",e.Message);
               throw e;
           }
       }

       public static bool DeleteAdminInfo(string adminID)
       {
           IAdminInfoDAL iAdminInfo = DALFactory<IAdminInfoDAL>.Create(typeNameKey);
           try
           {
               if (iAdminInfo.DeleteAdminInfo(adminID) > 0)
                   return true;
               else
                   return false;
           }
           catch (Exception e)
           {
               LogRecordHelper.LogNote("ERROR", e.Message);
               throw e;
           }
       }

       public static bool UpdateAdminInfo(Model.AdminInfo model)
       {
           IAdminInfoDAL iAdminInfo = DALFactory<IAdminInfoDAL>.Create(typeNameKey);
           try
           {
               if (iAdminInfo.UpdateAdminInfo(model) > 0)
               {
                   return true;
               }
               else
                   return false;
           }
           catch (Exception e)
           {
               LogRecordHelper.LogNote("ERROR", e.Message);
               throw e;
           }
       }

       public static bool Exists(string Administrator_Name)
       {
           IAdminInfoDAL iAdminInfo = DALFactory<IAdminInfoDAL>.Create(typeNameKey);

           try
           {
               return iAdminInfo.Exists(Administrator_Name);
           }
           catch (Exception e)
           {
               LogRecordHelper.LogNote("ERROR", e.Message);
               throw e;
           }
       }

       public static List<Model.AdminInfo> GetPagedAdminInfo(int size, int pageIndex, string where)
       {
           IAdminInfoDAL iAdminInfo = DALFactory<IAdminInfoDAL>.Create(typeNameKey);

           try
           {
               return iAdminInfo.GetPagedAdminInfo(size, pageIndex, where);
           }
           catch (Exception e)
           {
               LogRecordHelper.LogNote("ERROR", e.Message);
               throw e;
           }
       }

       public static Model.AdminInfo GetAdminInfo(string adminID)
       {
           IAdminInfoDAL iAdminInfo = DALFactory<IAdminInfoDAL>.Create(typeNameKey);
           try
           {
               return iAdminInfo.GetAdminInfo(adminID);
           }
           catch (Exception e)
           {
               LogRecordHelper.LogNote("ERROR", e.Message);
               throw e;
           }
       }

       public static int GetAdminInfoCount(string where)
       {
           IAdminInfoDAL iAdminInfo = DALFactory<IAdminInfoDAL>.Create(typeNameKey);

           try
           {
               return iAdminInfo.GetAdminInfoCount(where);
           }
           catch (Exception e)
           {
               LogRecordHelper.LogNote("ERROR", e.Message);
               throw e;
           }
       }
    }
}
